
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class Employees extends AbstractTableModel {
        private ArrayList<Employee> employees;
		  private String[] columnNames = {"First Name", "Last Name", "ID Number", "Profession"};
		  private Employee employee;

        public Employees(){
                employees = new ArrayList<Employee>();
        }
		  
		  @Override
			public String getColumnName(int column) {
   		 return columnNames[column];
			}

			@Override
			public int getColumnCount() {
	 		   return columnNames.length;
			}
		
			@Override
			public int getRowCount() {
		 	   return employees.size();
			}
			
			@Override
			public Object getValueAt(int rowIndex, int columnIndex) {
 	  			employee = (Employee)employees.get(rowIndex);
	  			switch (columnIndex) {
   	 			case 0:
    	   	 		return employee.getFirstName();
    				case 1:
     	 	 			return employee.getLastName();
					case 2:
						return employee.getId();
					case 3:
						return employee.getEmpType();
					default:
     		  			return null;
      	}
	}

		        
        public void addEmployee(Employee e){
                employees.add(e);
					 this.fireTableDataChanged();
        }
        
        public void removeEmployee(Employee e){
				if(!employees.isEmpty()){         
					 employees.remove(e);
					 this.fireTableDataChanged();
				}
        }
		  
		  public void removeAt(int i){
		  		if(!employees.isEmpty() && i >= 0){         
					 employees.remove(i);
					 this.fireTableDataChanged();
				}
		  }
        
        public Employee get(int i) {
                return employees.get(i);
        }
        
        public int getSize(){
                return employees.size();
        }
        
        
}